package com.lkd.handler;
import cn.hutool.json.JSONUtil;
import com.lkd.config.TopicConfig;
import com.lkd.contract.VendoutResultContract;
import com.lkd.emq.annotation.Topic;
import com.lkd.emq.handler.MsgHandler;
import com.lkd.service.OrderService;
import com.lkd.service.VendingMachineService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.IOException;


@Component
@Topic(TopicConfig.VMS_RESULT_TOPIC)
@Slf4j
public class VendoutResultMsgHandler implements MsgHandler{

  @Autowired
    private VendingMachineService vmService;


    @Override
    public void process(String jsonMsg) throws IOException {
        log.info("接收终端出货结果");
        //json转java
        VendoutResultContract vendoutResultContract = JSONUtil.toBean(jsonMsg, VendoutResultContract.class);
        //2.调用service处理业务
        vmService.vendoutResult(vendoutResultContract);
    }
}
